import config from "./config"
export const request = (params) => {
	return new Promise((resolve, reject) => {
		switch (params.type) {
			case "get":
				params.method = "GET";
				break;
			case "post":
				params.method = "POST";
				break;
			default:
				params.method = "GET";
		}
		delete params.type
        params.url = config.url + params.url
		wx.request({
            ...params,
            success: (res) => {
                resolve(res.data)
            },
            fail: (err) => {
                reject(err)
            }
        })
	})
}